package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TWaybillTracke;
import com.ruoyi.system.service.ITWaybillTrackeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 运踪Controller
 * 
 * @author ruoyi
 * @date 2025-03-22
 */
@RestController
@Api("运踪信息管理")
@RequestMapping("/system/tracke")
public class TWaybillTrackeController extends BaseController
{
    @Autowired
    private ITWaybillTrackeService tWaybillTrackeService;

    /**
     * 查询运踪列表
     */
    //@PreAuthorize("@ss.hasPermi('system:tracke:list')")
    @GetMapping("/list")
    @ApiOperation(value = "运踪列表")
    public TableDataInfo list(TWaybillTracke tWaybillTracke)
    {
        startPage();
        List<TWaybillTracke> list = tWaybillTrackeService.selectTWaybillTrackeList(tWaybillTracke);
        return getDataTable(list);
    }

    /**
     * 导出运踪列表
     */
    //@PreAuthorize("@ss.hasPermi('system:tracke:export')")
    @Log(title = "运踪", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TWaybillTracke tWaybillTracke)
    {
        List<TWaybillTracke> list = tWaybillTrackeService.selectTWaybillTrackeList(tWaybillTracke);
        ExcelUtil<TWaybillTracke> util = new ExcelUtil<TWaybillTracke>(TWaybillTracke.class);
        util.exportExcel(response, list, "运踪数据");
    }

    /**
     * 获取运踪详细信息
     */
    //@PreAuthorize("@ss.hasPermi('system:tracke:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation(value = "运踪详情")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tWaybillTrackeService.selectTWaybillTrackeById(id));
    }

    /**
     * 新增运踪
     */
    //@PreAuthorize("@ss.hasPermi('system:tracke:add')")
    @Log(title = "运踪", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation(value = "运踪新增")
    public AjaxResult add(@RequestBody TWaybillTracke tWaybillTracke)
    {
        return toAjax(tWaybillTrackeService.insertTWaybillTracke(tWaybillTracke));
    }

    /**
     * 修改运踪
     */
    //@PreAuthorize("@ss.hasPermi('system:tracke:edit')")
    @Log(title = "运踪", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value = "运踪编辑")
    public AjaxResult edit(@RequestBody TWaybillTracke tWaybillTracke)
    {
        return toAjax(tWaybillTrackeService.updateTWaybillTracke(tWaybillTracke));
    }

    /**
     * 删除运踪
     */
    //@PreAuthorize("@ss.hasPermi('system:tracke:remove')")
    @Log(title = "运踪", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation(value = "运踪删除")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tWaybillTrackeService.deleteTWaybillTrackeByIds(ids));
    }
}
